home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / moreisbetter / mib-libraries / moredevices / interruptsafedebug / interruptsafedebug.s < prev   
Encoding:
Text File  |  2000-06-23  |  1.6 KB  |  43 lines

  1. #    File:        InterruptSafeDebug.s
  2. #
  3. #    Contains:    Atomic add for systems without DriverServicesLib.
  4. #
  5. #    Written by:    Quinn
  6. #
  7. #    Copyright:    Copyright © 1998 by Apple Computer, Inc., all rights reserved.
  8. #
  9. #                You may incorporate this Apple sample source code into your program(s) without
  10. #                restriction. This Apple sample source code has been provided "AS IS" and the
  11. #                responsibility for its operation is yours. You are not permitted to redistribute
  12. #                this Apple sample source code as "Apple sample source code" after having made
  13. #                changes. If you're going to re-distribute the source, we require that you make
  14. #                it clear in the source that the code was descended from Apple sample source
  15. #                code, but that you've made changes.
  16. #
  17. #    Change History (most recent first):
  18. #
  19. #        <4>    23/11/98    Quinn   Fix header (again).
  20. #        <3>    23/11/98    Quinn   Testing CWProjector's header.
  21. #        <2>    23/11/98    Quinn   Fix header.
  22. #        <1>    23/11/98    Quinn   First checked in.
  23.  
  24. #    WARNING
  25. #    Do not use this routine on a machine that has a real implementation
  26. #    of AddAtomic.  If the machine has DriverServicesLib (or InterfaceLib
  27. #    from Mac OS 8.5 or later), use the AddAtomic implementation in
  28. #    preference to this implementation.
  29.  
  30. # extern UInt32 AddAtomicForNonDSL(UInt32 amount, UInt32 *value);
  31.  
  32.         csect    .AddAtomicForNonDSL{PR}
  33.         export    .AddAtomicForNonDSL{PR}
  34.  
  35. AddAtomicForNonDSL:
  36. @again:
  37.         lwarx    r5,r0,r4        # fetch the original
  38.         add        r5,r5,r3        # create updated value
  39.         stwcx.    r5,r0,r4        # try storing back
  40.         bne-    @again            # if store didn't happen, try again
  41.         sync
  42.         blr                        # result remains in r3
  43.